#include <stdio.h>

enum ErrorCode{
    //错误码
    ERROR_CODE_SUCCESS = 0,
    ERROR_CODE_FAILED = 1,
    ERROR_CODE_NOT_FILE = 2,
    ERROR_CODE_INVALID_PARAM = 3,
    ERROR_CODE_OUT_OF_MEMORY = 4,
    ERROR_CODE_IO_ERROR = 5,
};

enum ErrorCode errorCode = ERROR_CODE_SUCCESS;

//错误码对应的错误信息
const char*err[100] = {
    [ERROR_CODE_SUCCESS] = "成功",
    [ERROR_CODE_FAILED] = "失败",
    [ERROR_CODE_NOT_FILE] = "不是文件",
    [ERROR_CODE_INVALID_PARAM] = "无效的参数",
    [ERROR_CODE_OUT_OF_MEMORY] = "内存不足",
    [ERROR_CODE_IO_ERROR] = "IO错误",
};
//err[0] 等价于  err[ERROR_CODE_SUCCESS]       err[1]   等价于  err[ERROR_CODE_FAILED]  err[2] 

char* myPerror()
{
    return err[errorCode];
}

int myOpen(const char*pathName)
{
    if(pathName == NULL)
    {
        errorCode = ERROR_CODE_FAILED;
        return -1;
    }
}


int main()
{
    int fd = myOpen("test.txt");
    if(fd == -1)
    {
        myPerror();
    }

    return 0;
}